//
// Created by 谢哲 on 2021/5/16.
//

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    string s;
    cin >> s;
    vector<bool> vdata(s.length(), false);

    int len = s.length();
    for (int i=0; i<len; ++i) {
        if (s[i] == ')') {
            // Find rightmost (
            for (int j = i-1; j>=0; --j) {
                if (s[j] == '[' && !vdata[j]) {break;}
                if (s[j] == '(' && !vdata[j]) {
                    vdata[j] = true;
                    vdata[i] = true;
                    break;
                }
            }
        }
        else if (s[i] == ']') {
            // Find rightmost [
            for (int j = i-1; j>=0; --j) {
                if (s[j] == '(' && !vdata[j]) {break;}
                if (s[j] == '[' && !vdata[j]) {
                    vdata[j] = true;
                    vdata[i] = true;
                    break;
                }
            }
        }
    }

    string ans;
    for (int i=0; i<len; ++i) {
        if (!vdata[i]) {
            if (s[i] == '[' || s[i] == ']') {
                ans += "[]";
            }
            else {
                ans += "()";
            }
        }
        else {
            ans += s[i];
        }
    }

    cout << ans;

    return 0;
}
